package app

import (
	"github.com/gin-gonic/gin"
	"go_auth/ext/e"
)

type Gin struct {
	C *gin.Context
}

func (g *Gin) Response(httpCode, code int, data interface{}) {
	g.C.JSON(httpCode, gin.H{
		"code": code,
		"msg":  e.GetMsg(code),
		"data": data,
	})

	return
}

func (g *Gin) ResponseNum(httpCode, code, count int, data interface{}) {
	g.C.JSON(httpCode, gin.H{
		"count": count,
		"msg":   e.GetMsg(code),
		"data":  data,
	})

	return
}

func (g *Gin) CheckResponse(httpCode, code int, data interface{}) {
	g.C.JSON(httpCode, gin.H{
		"code": code,
		"msg":  e.GetMsg(code),
		"data": data,
	})

	g.C.Abort()
	return
}
